#include"comm.hpp"
using namespace std;

int main()
{
    Log log;

    int fd = open(PATHFILE, O_WRONLY); //客服端以写的方式打开
    if(fd < 0)
    {
        log(Fatal, "error message:%s\n", strerror(errno));
        exit(FILE_OPEN_ERROR);
    }
    sleep(1);
    int shmid = GetShm();
    if(shmid < 0)
    {
        log(Fatal, "get error: %s", strerror(errno));
        exit(1);
    }
    //链接
    char* shmaddr = (char*)shmat(shmid, nullptr, 0);

    //使用
    while(true)
    {
        cout << "Please Enter a message to severs:" ;
        fgets(shmaddr, 4096, stdin); //直接输入

        write(fd, "c", 1); // 通知对方 — 同步
    }

    shmdt(shmaddr);
    close(fd);
    return 0;
}